package com.huawei.m2m.cig.decoder.hxushen.wxushen.generate.message;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.huawei.m2m.cig.decoder.protocol.InputBuffer;
import com.huawei.m2m.cig.decoder.protocol.NBMessage;
import com.huawei.m2m.cig.decoder.protocol.OutputBuffer;

public class uploadlink
  extends NBMessage
{
  public uploadlink()
  {
    setName("uploadlink");
    setMessageId(47);
    setType("deviceReq");
  }
  
  private int messageId = 47;
  private int length;
  private String value;
  
  public int getMessageId()
  {
    return this.messageId;
  }
  
  public void setMessageId(int paramInt)
  {
    this.messageId = paramInt;
  }
  
  public int getLength()
  {
    return this.length;
  }
  
  public void setLength(int paramInt)
  {
    this.length = paramInt;
  }
  
  public String getValue()
  {
    return this.value;
  }
  
  public void setValue(String paramString)
  {
    this.value = paramString;
  }
  
  public void encode(OutputBuffer paramOutputBuffer)
  {
    paramOutputBuffer.putByte(this.messageId);
    paramOutputBuffer.putInt16(this.length);
    paramOutputBuffer.putString(this.value, "UTF-8");
  }
  
  public void decode(InputBuffer paramInputBuffer)
  {
    if (paramInputBuffer.getRemainingLength() >= 1) {
      this.messageId = paramInputBuffer.getByte();
    }
    if (paramInputBuffer.getRemainingLength() >= 2) {
      this.length = paramInputBuffer.getInt16();
    }
    int i = (this.length & 0xFF) + 0;
    if (paramInputBuffer.getRemainingLength() >= i) {
      this.value = paramInputBuffer.getString(i, "UTF-8");
    }
  }
  
  public ObjectNode toJsonNode()
  {
    ObjectMapper localObjectMapper = new ObjectMapper();
    ObjectNode localObjectNode1 = localObjectMapper.createObjectNode();
    localObjectNode1.put("msgType", "deviceReq");
    


    ArrayNode localArrayNode = localObjectMapper.createArrayNode();
    
    ObjectNode localObjectNode2 = localObjectMapper.createObjectNode();
    localObjectNode2 = localObjectMapper.createObjectNode();
    localObjectNode2.put("value", getValue());
    
    ObjectNode localObjectNode3 = localObjectMapper.createObjectNode();
    localObjectNode3.put("serviceId", "uplinkvalue");
    
    localObjectNode3.set("serviceData", localObjectNode2);
    
    localArrayNode.add(localObjectNode3);
    
    localObjectNode1.set("data", localArrayNode);
    
    return localObjectNode1;
  }
}
